﻿package mortal.game.view.copy.sunbathCopy.render
{
    import Message.Public.*;
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.button.*;
    import mortal.game.view.common.display.*;
    import mortal.mvc.core.*;

    public class SunbathCopyEnterViewRenderer extends GCellRenderer
    {
        private var _enterBtn:GLabelButton;
        private var _num:GTextFiled;
        private var _roomNum:BitmapNumberText;

        public function SunbathCopyEnterViewRenderer()
        {
            return;
        }// end function

        private function onClickItem(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SunbathCopyEnter, this.itemData.sunBathId));
            return;
        }// end function

        private function get itemData() : SSunBathInfo
        {
            return _data as SSunBathInfo;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._num.text = this.itemData.playerNum + "/30";
            this._roomNum.text = ((Cache.instance.copy.sunbath.sunBaths.indexOf(param1) + 1)).toString();
            return;
        }// end function

        private function onResCompl() : void
        {
            this._enterBtn.label = ImagesConst.SunbathCopyTxt4;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._enterBtn = UIFactory.gLabelButton("", GLabelButton.gLoadingButton, ResFileConst.SunbathCopyItemBtn, 0, 20, 139, 112, this);
            this._enterBtn.labelDx = -13;
            this._num = UIFactory.gTextField("", 0, 95, 110, 20, this, GlobalStyle.textFormatHuang2.center());
            this._roomNum = UIFactory.bitmapNumberText(41, 10, "SunbathCopyNum2.png", 32, 43, 2, this, 10);
            this._enterBtn.configEventListener(MouseEvent.CLICK, this.onClickItem);
            LoaderHelp.addResCallBack(ResFileConst.sunbathCopy, this.onResCompl);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            LoaderHelp.removeResEvent(ResFileConst.sunbathCopy, this.onResCompl);
            this._enterBtn.dispose(param1);
            this._num.dispose(param1);
            this._roomNum.dispose(param1);
            this._enterBtn = null;
            this._num = null;
            this._roomNum = null;
            return;
        }// end function

    }
}
